import path from 'path';
import puppeteer from 'puppeteer-extra';
// console.log(path.sep);
// // console.log(__dirname);
// // console.log(__filename);
// console.log(process.cwd());
// console.log(path.resolve('./'));
// console.log(filePath);
(async function () {
  const sep = path.sep;
  const htmlPath = `file://${path.resolve(
    './'
  )}${sep}html${sep}order-detail.html?data=%7B%22mobile%22%3A%2217872254985%22%2C%22order_num%22%3A%22202201291011100001050613%22%2C%22movie_name%22%3A%22%E9%BB%91%E5%AE%A2%E5%B8%9D%E5%9B%BD%EF%BC%9A%E7%9F%A9%E9%98%B5%E9%87%8D%E5%90%AF%22%2C%22movie_img_url%22%3A%22https%3A%2F%2Fimg.img.leying.com%2F2021%2F12%2F09%2Fb68c361d609fc7246659029ac4b338d8.png%22%2C%22cinema_name%22%3A%22%E4%B8%8A%E6%B5%B7%E7%99%BE%E4%B8%BD%E5%AE%AB%E5%BD%B1%E5%9F%8E%EF%BC%88%E5%8D%9A%E8%8D%9F%E5%B9%BF%E5%9C%BA%E5%BA%97%EF%BC%89%22%2C%22hall_name%22%3A%22%E6%BF%80%E5%85%895%E5%8F%B7%E5%8E%85%22%2C%22seat_info%22%3A%22I%E6%8E%927%E5%8F%B7%2CI%E6%8E%928%E5%8F%B7%2CI%E6%8E%929%E5%8F%B7%2CI%E6%8E%926%E5%8F%B7%22%2C%22start_date%22%3A%222022-01-29%22%2C%22start_time%22%3A%2214%3A20%3A00%22%2C%22create_time%22%3A%222022-01-29%2010%3A11%3A59%22%2C%22movie_format%22%3A%22%E8%8B%B1%E8%AF%AD%2F2D%22%2C%22msg%22%3A%22%E8%B4%AD%E7%A5%A8%E6%88%90%E5%8A%9F%22%2C%22total_price%22%3A%22220%22%2C%22serial_number_1%22%3A%22351584%22%2C%22serial_number_2%22%3A%22128148%22%2C%22seats%22%3A%5B%7B%22seat_name%22%3A%22%E6%99%AE%E9%80%9A%E5%BA%A7%E6%A4%85%22%2C%22seat_count%22%3A%224%22%2C%22seat_price%22%3A%22220%22%2C%22area_total_service_fee%22%3A%220%22%7D%5D%2C%22message%22%3A%22*%E4%B8%8D%E5%85%81%E8%AE%B8%E9%80%80%E7%A5%A8%22%2C%22tel%22%3A%22021-63357505%22%7D`;

  // 初始化
  const browser = await puppeteer.launch({
    executablePath:
      '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
    //设置超时时间
    timeout: 15000,
    ignoreHTTPSErrors: true,
    headless: true,
    args: ['--disable-dev-shm-usage', '--no-sandbox', '--disable-plugins'],
  });
  const page = await browser.newPage();
  console.log(htmlPath)
  await page.goto(htmlPath);
  await page.setViewport({
    width: 375,
    height: 590,
  });
  await page.screenshot({
    path: '1.png',
  });

  await browser.close();
})();
